<?php

/*
 * 
 * Script por Josiel Novaes
 * 
 */

include_once '../classes/includes/ConnectBD.php';
include_once '../classes/includes/NoSqlInjection.php';
 
 class Autentica{
 	
 	 private $connect;
 	 
	 public function __construct(){
	 	if($this->connect == null){
	 	$this->connect =  new ConnectBD();
	 	}
	 }	
	
	 public function __destruct(){

	 	if($this->connect != null){
		$this->connect->__destruct();
	 	}
	 }
	 
	 public function login($login,$senha,$verificador){
	 	
	 	/*
	 	$noSqlInjection = new NoSqlInjection();
	 	$paramns = array(1 => $login,2 => $senha);
	 	$paramns = $noSqlInjection->verificaNoSqlInjection($paramns);
	 	
	 	$login = $paramns[1];
	 	$senha = $paramns[2];
	 	*/
	 	
		 if($verificador == true){
		 	
		 	$consulta = $this->connect->getQueryWithParamns("login","login,senha","login='".$login."' and senha='".$senha."' ");
		 	if(mysql_num_rows($consulta) > 0){
			 	
		 		while($usuarios = mysql_fetch_array($consulta)){
			 		
		 			$pLogin = $usuarios['login'];
			 		$pSenha = $usuarios['senha'];
			 		
			 		if(($login == $pLogin) && ($senha == $pSenha)){
			 			return true;
			 		}else{
			 		return false;
			 		}
			 	}
			 	
		 	}else{
		 	return false;	
		 	}	 	
		 }else{	
		 	return false;
		 }
		 
	 }
 	
 	
 }


 
 ?>
	